Check Linkset for given Linkmodul name exists

Hi everyone,

I have a question about Linkset. I have a string, which name of Linkmodul is. Using Doors dxl, I want to check, Linkset for this Linkmodul exists or not?

Thanks in advance

Jonny


Jonny Tim - Thu Nov 08 06:46:04 EST 2018

Re: Check Linkset for given Linkmodul name exists
Mike.Scharnow - Thu Nov 08 07:49:23 EST 2018

Link sets are objects in the link module. You can iterate over the existing link sets in the link module. Something like this:

Module lnkmod = edit((fullName_of_link_module), false)
if(null lnkmod) { 
        // link module does not exist? Error condition or create link module
        ...
}
bool found = false
Object lnkObj 
for lnkObj in lnkmod do
        {     // in the link module, find the source/target combo
                found = ((lnkObj."Source" "") == (fullName modSource)) &&
                                ((lnkObj."Target" "") == (fullName modTarget))
                if(found) { break }
}
if (!found) {
        // create link set
}

 

Re: Check Linkset for given Linkmodul name exists
Jonny Tim - Mon Nov 12 15:49:37 EST 2018

Mike.Scharnow - Thu Nov 08 07:49:23 EST 2018

Link sets are objects in the link module. You can iterate over the existing link sets in the link module. Something like this:

Module lnkmod = edit((fullName_of_link_module), false)
if(null lnkmod) { 
        // link module does not exist? Error condition or create link module
        ...
}
bool found = false
Object lnkObj 
for lnkObj in lnkmod do
        {     // in the link module, find the source/target combo
                found = ((lnkObj."Source" "") == (fullName modSource)) &&
                                ((lnkObj."Target" "") == (fullName modTarget))
                if(found) { break }
}
if (!found) {
        // create link set
}

 

Hi Mike,

Thanks for your answer. But what is the meaning of "" in this line

lnkObj."Source" ""

Re: Check Linkset for given Linkmodul name exists
Mike.Scharnow - Tue Nov 13 05:46:02 EST 2018

Jonny Tim - Mon Nov 12 15:49:37 EST 2018

Hi Mike,

Thanks for your answer. But what is the meaning of "" in this line

lnkObj."Source" ""

it is about casting to the correct type.

 

myVariable = myObject."myAttribute"

is ambiguous, if myVariable is not declared: it could mean that myVariable shall be a reference to the attribute, the corresponding perm would be 

Attr__ ::. (Object, string)

So, if you explicitely need the VALUE of an attribute, you need to tell this to DXL. Usually this is done by casting.

string myVal = myObject."myAttribute"

is unambiguous: the result shall be of type string, so DOORS knows that has to take the reference (Attr__) and cast it to "string", which means that it has to extract the value of the attribute and that the value is of type string. The perm would be

string ::= (Attr__, string)

You can enforce the type cast by several methods

  • assign something to a variable of type string: → string x = y
  • cast explicitely by giving the type (see DXL reference manual: Expressions: cast) → x = y string     or     x = (string y)
  • concatenate something with a string, e.g. an empty string → x = y ""